package jwdt.xadmin.system.action;

import jwdt.common.action.BaseAction;
import jwdt.xadmin.system.bean.FLMX;
import jwdt.xadmin.system.service.FlmxManageService;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/system")
public class FlmxManageAction extends BaseAction {
	
	private FlmxManageService flmxManageService = (FlmxManageService)app.getBean("flmxManageService");
	
	@RequestMapping("/listFlmx")
	public Page doListFl(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		int flid = f.getInt("flid");
    	return m.getWritePage(f, flmxManageService.doList(pu,flid).toJson());
	}
	
	@RequestMapping("/addFlmx")
	public Page doAddact(Form f, Module m) throws Exception {
		FLMX obj = (FLMX)f.copy2Class(FLMX.class);
		return m.getWritePage(f, flmxManageService.doAddact(obj));
	}
	
	@RequestMapping("/editFlmx")
	public Page doEditact(Form f, Module m) throws Exception {
		int mxid = f.getInt("mxid");
		FLMX obj = (FLMX)f.copy2Class(FLMX.class);
		return m.getWritePage(f, flmxManageService.doEditact(obj, mxid));
	}
	
	@RequestMapping("/delFlmx")
	public Page doDel(Form f, Module m) throws Exception {
		int mxid = f.getInt("mxid");
		return m.getWritePage(f, flmxManageService.doDelact(mxid));
	}
	
	@RequestMapping("/flmxWindow")
	public Page doLoad(Form f, Module m) throws Exception {
		int mxid = f.getInt("mxid");
		f.add("obj", flmxManageService.doLoad(mxid));
		return m.findPage("/xadmin/system/flmxWindow");
	}
	
	@RequestMapping("/listFlmxForCombox")
	public Page doListFlmxForCombox(Form f, Module m) throws Exception {
		int flid = f.getInt("flid");
		//生成json字符串
    	return m.getJsonPage(f, flmxManageService.doListForCombo(flid));
	}
	
	@RequestMapping("/updateMxState")
	public Page doUpdateMxState(Form f, Module m) throws Exception {
		int mxid = f.getInt("mxid");
		int state = f.getInt("state");
		return m.getWritePage(f, flmxManageService.doUpdateMxState(mxid, state));
	}
	
}
